import 'package:flutter_wanandroid_ohos/generated/json/base/json_convert_content.dart';
import 'package:flutter_wanandroid_ohos/models/wx_chapter_entity.dart';

WxChapterEntity $WxChapterEntityFromJson(Map<String, dynamic> json) {
  final WxChapterEntity wxChapterEntity = WxChapterEntity();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    wxChapterEntity.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    wxChapterEntity.name = name;
  }
  final int? order = jsonConvert.convert<int>(json['order']);
  if (order != null) {
    wxChapterEntity.order = order;
  }
  final int? parentChapterId = jsonConvert.convert<int>(
      json['parentChapterId']);
  if (parentChapterId != null) {
    wxChapterEntity.parentChapterId = parentChapterId;
  }
  final int? type = jsonConvert.convert<int>(json['type']);
  if (type != null) {
    wxChapterEntity.type = type;
  }
  final bool? userControlSetTop = jsonConvert.convert<bool>(
      json['userControlSetTop']);
  if (userControlSetTop != null) {
    wxChapterEntity.userControlSetTop = userControlSetTop;
  }
  final int? visible = jsonConvert.convert<int>(json['visible']);
  if (visible != null) {
    wxChapterEntity.visible = visible;
  }
  return wxChapterEntity;
}

Map<String, dynamic> $WxChapterEntityToJson(WxChapterEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['order'] = entity.order;
  data['parentChapterId'] = entity.parentChapterId;
  data['type'] = entity.type;
  data['userControlSetTop'] = entity.userControlSetTop;
  data['visible'] = entity.visible;
  return data;
}

extension WxChapterEntityExtension on WxChapterEntity {
  WxChapterEntity copyWith({
    int? id,
    String? name,
    int? order,
    int? parentChapterId,
    int? type,
    bool? userControlSetTop,
    int? visible,
  }) {
    return WxChapterEntity()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..order = order ?? this.order
      ..parentChapterId = parentChapterId ?? this.parentChapterId
      ..type = type ?? this.type
      ..userControlSetTop = userControlSetTop ?? this.userControlSetTop
      ..visible = visible ?? this.visible;
  }
}